package com.hmall.item.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;

/**
 * @Author Vsunks.v
 * @Date 2022/8/10 11:42
 * @Blog blog.sunxiaowei.net/996.mba
 * @Description:
 */
@Component
public class TimeAndOpMetaObjectHandler implements MetaObjectHandler {
    Date date = Date.from(LocalDateTime.now().atZone( ZoneId.systemDefault()).toInstant());
    @Override
    public void insertFill(MetaObject metaObject) {
        metaObject.setValue("createTime",date);
        metaObject.setValue("updateTime",date);
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        metaObject.setValue("updateTime", date);
    }
}
